Skip to content

feat: Add tree components to the detail page and files page prelimina…#1162

Merged
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
larissa-la:main
Jun 25, 2025
Merged

feat: Add tree components to the detail page and files page prelimina…#1162
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
larissa-la:main

Conversation

@larissa-la

Copy link
Copy Markdown
Contributor

…rily, and modify the table icon styles.

@vercel

vercel Bot commented Jun 25, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 9:00am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates a tree component into both the repository tree and file‐blob views, adds a flag prop to control navigation behavior, and updates icon sizing and layout in the file diff sidebar.

  • Pass a flag prop to RepoTree in tree and blob pages and fetch/filter directory data in the blob page.
  • Replace the manual file list in FileDiff with the new TreeView component.
  • Adjust icon size and spacing in CodeTable.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pages/[org]/code/tree/[...path]/index.tsx Add flag="contents" to RepoTree
pages/[org]/code/blob/[...path].tsx Integrate RepoTree, fetch/filter tree data, add flag
components/DiffView/TreeView.tsx New rich tree‐view component with drag/drop and async load
components/DiffView/FileDiff.tsx Swap out file list for TreeView
components/CodeView/TreeView/RepoTree.tsx Extend RepoTree with flag, update navigation logic
components/CodeView/CodeTable.tsx Update icon sizes and spacing
Comments suppressed due to low confidence (2)

moon/apps/web/pages/[org]/code/blob/[...path].tsx:97

  • [nitpick] The name newDirectory is ambiguous (it actually holds filtered file items). Consider renaming to something like fileItems or filteredItems for clarity.
  const [newDirectory, setNewDirectory] = useState<any[]>([])

moon/apps/web/components/CodeView/TreeView/RepoTree.tsx:146

  • [nitpick] The prop name flag is vague. Consider renaming to something like viewMode or navigationMode with a typed union ('contents' | 'detail') for clarity.
const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {

Comment on lines 158 to 159
</Flex>
</Flex>

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two closing </Flex> tags in a row, which likely mismatches your JSX tree. Please remove the extra closing tag to fix the rendering hierarchy.

Suggested change
</Flex>
</Flex>
</Flex>
</Flex>

Copilot uses AI. Check for mistakes.
const [newDirectory, setNewDirectory] = useState<any[]>([])

// eslint-disable-next-line no-console
console.log(directory, 'directory==directory')

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover debugging console.log calls should be removed or replaced with a proper logger to avoid cluttering the console in production.

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +109
// eslint-disable-next-line no-console
console.log(filteredItems, 'filteredItems==');

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this debug console.log or gate it behind a development flag to keep production logs clean.

Suggested change
// eslint-disable-next-line no-console
console.log(filteredItems, 'filteredItems==');
if (process.env.NODE_ENV === 'development') {
console.log(filteredItems, 'filteredItems==');
}

Copilot uses AI. Check for mistakes.

return {
id: uuidv4(),
label: '我是文件夹',

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcoded placeholder '我是文件夹' should be replaced with item.name so that each node shows its actual folder name.

Suggested change
label: '我是文件夹',
label: item.name,

Copilot uses AI. Check for mistakes.
return (
<TreeItemProvider {...getContextProviderProps()}>
<TreeItemRoot {...getRootProps(other)}>
{item.label === '加载中...' ? (

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a hardcoded Chinese literal for loading ('加载中...') may not be expected in all locales—consider extracting to a constant or i18n resource.

Copilot uses AI. Check for mistakes.
}, [response, isLoading, error, loadPath, targetNodeId, treeData, convertToTreeData, updateTreeData]);


const handleNodeSelect = useCallback(

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleNodeSelect is empty and never performs any action. You likely need to implement navigation or a selection callback here.

Copilot uses AI. Check for mistakes.
Comment on lines +356 to 357
if (flag ==='contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigation on leaf click only happens when flag === 'contents'. The detail flag case is unhandled, so clicking in the blob page won't navigate—please adjust logic for both modes.

Suggested change
if (flag ==='contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);
if (flag === 'contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);
} else if (flag === 'detail' && node?.isLeaf) {
router.push(`/${scope}/code/detail${basePath}/${fullPath}`);

Copilot uses AI. Check for mistakes.
className='rounded-lg w-[300px] h-[85vh] p-2 overflow-y-auto sticky top-5'
>
<ul>
{/* <ul>

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a large commented‐out block of list code with mismatched braces. Please remove or properly format this dead code to keep the component clean.

Copilot uses AI. Check for mistakes.
@benjamin-747
benjamin-747 added this pull request to the merge queue Jun 25, 2025
Merged via the queue into gitmono-dev:main with commit 7f3436f Jun 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants